home *** CD-ROM | disk | FTP | other *** search
- ' Caption: XML validate...|
- ' Hint: Valida un documento XML|
- ' Icon: xmlvalidate.ico|
- '
- '
- ' Copyright (C) 2000-2003, Magoga Demis. All rights reserved.
- '
- ' The contents of this file are subject to the Mozilla Public License
- ' Version 1.1 (the "License"); you may not use this file except in compliance
- ' with the License. You may obtain a copy of the License at
- ' http://www.mozilla.org/MPL/
- '
- ' Software distributed under the License is distributed on an "AS IS" basis,
- ' WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- ' the specific language governing rights and limitations under the License.
- '
- ' The Initial Developer of the Original Code is Magoga Demis.
- ' Portions created by Magoga Demis are Copyright (C) 2000-2003 Magoga Demis.
- ' All Rights Reserved.
- '
- ' Contributor(s): .
- '
- ' Alternatively, the contents of this file may be used under the terms of the
- ' GNU General Public License Version 2 or later (the "GPL"), in which case
- ' the provisions of the GPL are applicable instead of those above.
- ' If you wish to allow use of your version of this file only under the terms
- ' of the GPL and not to allow others to use your version of this file
- ' under the MPL, indicate your decision by deleting the provisions above and
- ' replace them with the notice and other provisions required by the GPL.
- ' If you do not delete the provisions above, a recipient may use your version
- ' of this file under either the MPL or the GPL.
- '
- ' $Id: xmlvalidate.vbs,v 1.2.2.5 2003/08/13 00:38:45 neum Exp $
-
- ' Validate the Active XML Document
- '
- ' If you need, here the parseError properties:
- '
- ' Error #: parseError.errorCode
- ' Description: parseError.reason
- ' In file: parseError.url
- ' Line #: parseError.line
- ' Character # in line: parseError.linepos
- ' Character # in file: parseError.filepos
- ' Source line: parseError.srcText
-
-
- option explicit
-
- on error resume next
-
- ' microsoft parser version, you can add new version
- ' you can download msxml parser at http://www.microsoft.com/
- Dim msParserVersion
- msParserVersion = Array("Msxml.DOMDocument","Msxml2.DOMDocument")
-
- sub Main(dummy)
- if Documents.Count = 0 then
- MsgBox "No Document open.", vbCritical
- exit sub
- end if
- dim objDOMDoc
- dim version
- dim i
- version= "null"
-
- ' i try to create parser object and save the version
- for i = 0 to ubound(msParserVersion)
- if (IsObject(CreateObject(msParserVersion(i)))) <> "" then
- version=msParserVersion(i)
- exit for
- end if
- next
-
- ' if the microsoft component is not installed i invite to do
- if version = "null" then
- MsgBox ("You need Msxml parser" & vbCrLf & _
- "You can find it at http://www.microsoft.com/")
- exit sub
- end if
-
- ' i set the active document text to the parser and then:
- ' - if all is ok a message dialog is show
- ' - if an error is raised a message dialog is show and the line is highlight
- Set objDOMDoc= CreateObject(version)
- objDOMDoc.async = false
- if (objDOMDoc.loadXML(ActiveDocument.Text)) then
- MsgBox "Document is well formed and valid", vbInformation
- else
- MsgBox "Error in line: " & objDOMDoc.parseError.Line & vbCrLf & _
- "Reason: " & objDOMDoc.parseError.reason, vbExclamation
- ActiveDocument.HighlightLine objDOMDoc.parseError.Line, objDOMDoc.parseError.linepos, &hff
- end if
-
- end sub
-
-
-